package com.eastfair.builder.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.eastfair.core.base.entity.Entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.eastfair.database.mybatis.typehandler.M9EncryptHandler;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.builder.enumeration.ConstructionPersonnelGenderEnum;
import com.eastfair.builder.enumeration.ConstructionPersonnelWorkTypeEnum;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 施工人员信息
 * </p>
 *
 * @author linan
 * @since 2023-05-04
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "bd_construction_personnel", autoResultMap = true)
//@TableName(value = "bd_construction_personnel")
@ApiModel(value = "ConstructionPersonnel", description = "施工人员信息")
@AllArgsConstructor
public class ConstructionPersonnel extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 是否启用：1是；0否
     */
    @ApiModelProperty(value = "是否启用：1是；0否")
    @TableField(value = "is_enabled")
    @Excel(name = "是否启用：1是；0否")
    private Integer isEnabled;

    /**
     * 是否删除：1是；0否
     */
    @ApiModelProperty(value = "是否删除：1是；0否")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除：1是；0否")
    private Integer isDeleted;

    /**
     * 项目id
     */
    @ApiModelProperty(value = "项目id")
    @TableField(value = "project_id")
    @Excel(name = "项目id")
    private Long projectId;

    /**
     * 子系统id
     */
    @ApiModelProperty(value = "子系统id")
    @TableField(value = "subsystem_id")
    @Excel(name = "子系统id")
    private Long subsystemId;

    /**
     * 租户id
     */
    @ApiModelProperty(value = "租户id")
    @TableField(value = "tenant_id")
    @Excel(name = "租户id")
    private Long tenantId;

    /**
     * 姓名
     */
    @ApiModelProperty(value = "姓名")
    @Size(max = 255, message = "姓名长度不能超过255")
    @TableField(value = "name", condition = LIKE)
    @Excel(name = "姓名")
    private String name;

    /**
     * 性别 #{MALE:男;FEMALE:女}
     */
    @ApiModelProperty(value = "性别 #{MALE:男;FEMALE:女}")
    @TableField(value = "gender")
    @Excel(name = "性别 #{MALE:男;FEMALE:女}", replace = {"男_MALE", "女_FEMALE",  "_null"})
    private ConstructionPersonnelGenderEnum gender;

    /**
     * 身份证号
     */
    @ApiModelProperty(value = "身份证号")
    @Size(max = 255, message = "身份证号长度不能超过255")
    @TableField(value = "card_number", condition = LIKE, typeHandler = M9EncryptHandler.class)
//    @TableField(value = "card_number", condition = LIKE)
    @Excel(name = "身份证号")
    private String cardNumber;

    /**
     * 工种 #{HIGH_ALTITUDE_WORK_PERMIT:高空作业证;ELECTRICIAN_CERT:电工证;OTHER:其他证;}
     */
    @ApiModelProperty(value = "工种 #{HIGH_ALTITUDE_WORK_PERMIT:高空作业证;ELECTRICIAN_CERT:电工证;OTHER:其他证;}")
    @TableField(value = "work_type")
    @Excel(name = "工种 #{HIGH_ALTITUDE_WORK_PERMIT:高空作业证;ELECTRICIAN_CERT:电工证;OTHER:其他证;}", replace = {"高空作业证_HIGH_ALTITUDE_WORK_PERMIT", "电工证_ELECTRICIAN_CERT", "其他证_OTHER",  "_null"})
    private ConstructionPersonnelWorkTypeEnum workType;

    /**
     * 报馆ID
     */
    @ApiModelProperty(value = "报馆ID")
    @TableField(value = "report_space_id")
    @Excel(name = "报馆ID")
    private Long reportSpaceId;


    @Builder
    public ConstructionPersonnel(Long id, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime, 
                    Integer isEnabled, Integer isDeleted, Long projectId, Long subsystemId, Long tenantId, 
                    String name, ConstructionPersonnelGenderEnum gender, String cardNumber, ConstructionPersonnelWorkTypeEnum workType, Long reportSpaceId) {
        this.id = id;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
        this.projectId = projectId;
        this.subsystemId = subsystemId;
        this.tenantId = tenantId;
        this.name = name;
        this.gender = gender;
        this.cardNumber = cardNumber;
        this.workType = workType;
        this.reportSpaceId = reportSpaceId;
    }

}
